<?php
if (! defined ( 'BASEPATH' )) {
	exit ( 'no direct script access allowed!' );
}
/**
 * 用户表数据操作
 * Enter description here ...
 * @author 庆安
 *
 */
class user_model extends CI_Model {
	function __construct() {
		parent::__construct ();
		$this->load->library ( 'code_fragment' );
	}
	function queryOneUserInfo($data) {
		if (! empty ( $data ["perserteeId"] )) {
			$this->db->where ( "userId", $data ["perserteeId"] );
			return $this->db->get ( "wanwan_enum_user" )->row_array ();
		}
	}
	function updatePersonalInfo($data,$table){
		$this->db->where('id',$data['id']);
		$this->db->update($table,$data);
		return $this->db->affected_rows();
	}
	function getUserNameDelTag($data) {
		$array = explode ( ",", $data ['Id'] );
		$tag = "";
		foreach ( $array as $value ) {
			$rs = $this->queryOneUserInfo ( array ('perserteeId' => $value ) );
			if (! empty ( $rs )) {
				$tag .= $this->code_fragment->userNameDelTag ( $rs );
			}
		}
		log_message ( "info", "userTag" . $tag );
		return $tag;
	}
	
	function getTeamInfoAll($data,$beginNumber,$pageSize) {
		$rs = $this->db->get_where ( 'wanwan_enum_usertoteam', $data,$pageSize,$beginNumber-1 );
		return  $rs->result_array ();
	}
	
	function getTeamInfo($data) {
		$this->db->select ( 'teamId,teamName' );
		$rs = $this->db->get_where ( 'wanwan_enum_usertoteam', $data );
		return json_encode ( $rs->result_array () );
	}
}